package command;

import java.util.HashMap;
import java.util.Map;

import command.Impl.ExitCommand;
import command.Impl.HelpCommand;
import command.Impl.LoginCommand;
import command.Impl.SelectCommand;
import command.Impl.SignUpCommand;

public class SystemCommandFactory extends AbstractCommandFactory{
	static Map<CommandCode ,Class <? extends Command>>map = new HashMap<CommandCode ,Class <? extends Command>>();
	static{
		map.put(CommandCode.EXIT , ExitCommand.class);
		map.put(CommandCode.HELP , HelpCommand.class);
		map.put(CommandCode.LOGIN , LoginCommand.class);
		map.put(CommandCode.SELECT , SelectCommand.class);
		map.put(CommandCode.SIGNUP , SignUpCommand.class);
	}
	public Command buildCommand(CommandCode cmd) {
		if(map.get(cmd) != null){
			try {
				// System.out.println(map.get(cmd).newInstance());
				return map.get(cmd).newInstance();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return null ;
	}
}
